<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        深复制（克隆）
        浅复制（克隆）
      */

      const user = {
        name: 'jack',
        age: '20',
        size: {
          h: 100,
          w: 200,
        },
      };
      // const user1 = { ...user };
      const user1 = JSON.parse(JSON.stringify(user));
      user1.size.h = 800;
      console.log(user1.size.h); //800
      console.log(user.size.h); //800
      console.log(user === user1); //false
    </script>
  </body>
</html>
